package reamodel.diagram.part;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

import reamodel.diagram.providers.REAmetamodelElementTypes;

/**
 * @generated
 */
public class REAmetamodelPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createREAPolicyNodes1Group());
		paletteRoot.add(createREAOperationalNodes2Group());
		paletteRoot.add(createConnections3Group());
	}

	/**
	 * Creates "REA Policy Nodes" palette tool group
	 * @generated
	 */
	private PaletteContainer createREAPolicyNodes1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.REAPolicyNodes1Group_title);
		paletteContainer.setDescription(Messages.REAPolicyNodes1Group_desc);
		paletteContainer.add(createEconomicResourceType1CreationTool());
		paletteContainer.add(createDecrementEconomicEventType2CreationTool());
		paletteContainer.add(createIncrementEconomicEventType3CreationTool());
		paletteContainer.add(createEconomicAgentType4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "REA Operational Nodes" palette tool group
	 * @generated
	 */
	private PaletteContainer createREAOperationalNodes2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.REAOperationalNodes2Group_title);
		paletteContainer
				.setDescription(Messages.REAOperationalNodes2Group_desc);
		paletteContainer.add(createEconomicResource1CreationTool());
		paletteContainer.add(createIncrementEconomicEvent2CreationTool());
		paletteContainer.add(createDecrementEconomicEvent3CreationTool());
		paletteContainer.add(createEconomicAgent4CreationTool());
		paletteContainer.add(createIncrementCommitment5CreationTool());
		paletteContainer.add(createDecrementCommitment6CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Connections" palette tool group
	 * @generated
	 */
	private PaletteContainer createConnections3Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Connections3Group_title);
		paletteContainer.setDescription(Messages.Connections3Group_desc);
		paletteContainer.add(createConnection1CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEconomicResourceType1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.EconomicResourceType_1001);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.EconomicResourceType1CreationTool_title,
				Messages.EconomicResourceType1CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.EconomicResourceType_1001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDecrementEconomicEventType2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.DecrementEconomicEventType_1003);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.DecrementEconomicEventType2CreationTool_title,
				Messages.DecrementEconomicEventType2CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.DecrementEconomicEventType_1003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createIncrementEconomicEventType3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.IncrementEconomicEventType_1004);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.IncrementEconomicEventType3CreationTool_title,
				Messages.IncrementEconomicEventType3CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.IncrementEconomicEventType_1004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEconomicAgentType4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.EconomicAgentType_1002);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.EconomicAgentType4CreationTool_title,
				Messages.EconomicAgentType4CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.EconomicAgentType_1002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEconomicResource1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.EconomicResource_1006);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.EconomicResource1CreationTool_title,
				Messages.EconomicResource1CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.EconomicResource_1006));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createIncrementEconomicEvent2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.IncrementEconomicEvent_1008);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.IncrementEconomicEvent2CreationTool_title,
				Messages.IncrementEconomicEvent2CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.IncrementEconomicEvent_1008));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDecrementEconomicEvent3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.DecrementEconomicEvent_1007);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.DecrementEconomicEvent3CreationTool_title,
				Messages.DecrementEconomicEvent3CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.DecrementEconomicEvent_1007));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEconomicAgent4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.EconomicAgent_1005);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.EconomicAgent4CreationTool_title,
				Messages.EconomicAgent4CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.EconomicAgent_1005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createIncrementCommitment5CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.IncrementCommitment_1009);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.IncrementCommitment5CreationTool_title,
				Messages.IncrementCommitment5CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.IncrementCommitment_1009));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDecrementCommitment6CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(REAmetamodelElementTypes.DecrementCommitment_1010);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.DecrementCommitment6CreationTool_title,
				Messages.DecrementCommitment6CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelElementTypes
						.getImageDescriptor(REAmetamodelElementTypes.DecrementCommitment_1010));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnection1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(19);
		types.add(REAmetamodelElementTypes.EconomicResourceTypeTypify_3001);
		types.add(REAmetamodelElementTypes.Outflow_3002);
		types.add(REAmetamodelElementTypes.Inflow_3003);
		types
				.add(REAmetamodelElementTypes.DecrementEconomicEventTypeTypify_3004);
		types
				.add(REAmetamodelElementTypes.IncrementEconomicEventTypeTypify_3005);
		types.add(REAmetamodelElementTypes.OutflowType_3006);
		types.add(REAmetamodelElementTypes.InflowType_3007);
		types.add(REAmetamodelElementTypes.EconomicAgentTypeTypify_3008);
		types.add(REAmetamodelElementTypes.ReceiveParticipation_3009);
		types.add(REAmetamodelElementTypes.ProvideParticipation_3010);
		types.add(REAmetamodelElementTypes.IncrementEconomicEventDuality_3011);
		types
				.add(REAmetamodelElementTypes.IncrementEconomicEventTypeDualityType_3012);
		types.add(REAmetamodelElementTypes.CommitmentAgent_3013);
		types.add(REAmetamodelElementTypes.CommitmentResource_3014);
		types.add(REAmetamodelElementTypes.IncrementCommitmentFulfill_3015);
		types.add(REAmetamodelElementTypes.DecrementCommitmentFulfill_3016);
		types.add(REAmetamodelElementTypes.IncrementCommitmentReciprocity_3017);
		types.add(REAmetamodelElementTypes.DecrementCommitmentSpecify_3018);
		types.add(REAmetamodelElementTypes.IncrementCommitmentSpecify_3019);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Connection1CreationTool_title,
				Messages.Connection1CreationTool_desc, types);
		entry
				.setSmallIcon(REAmetamodelDiagramEditorPlugin
						.findImageDescriptor("/REAModeller.edit/icons/full/obj16/Connection.gif")); //$NON-NLS-1$
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
